package com.lu.spzx.product.controller;

import com.lu.spzx.model.entity.product.Category;
import com.lu.spzx.model.vo.common.Result;
import com.lu.spzx.model.vo.common.ResultCodeEnum;
import com.lu.spzx.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/api/product/category")
@SuppressWarnings({"unchecked", "rawtypes"})
// 网关中已经配置,不需要重复配置
// @CrossOrigin
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    // 获取分类树形数据
    @GetMapping("findCategoryTree")
    public Result<List<Category>> findCategoryTree() {
        List<Category> list = this.categoryService.findCategoryTree();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }

}